<template>
  <div class="view-container">

    <table-search-view ref="orderView" :search-items="searchItems" :table-items="tableItems" :search-function="search">
      <template slot="action" slot-scope="scope">
        <action-deliver :scope="scope" @deliver-success="successDeliver"></action-deliver>
        <action-info :scope="scope"></action-info>
      </template>
    </table-search-view>

  </div>
</template>

<script>
  import TableSearchView from '@/components/TableSearchView';

  import actionOrderInfo from './components/actionOrderInfo.vue';
  import actionDeliver from './components/actionDeliver.vue';
  import {getOrderPendingDeliverList} from '@/api/order';

  export default {
    name: 'orderPendingDeliver', /*待发货订单*/
    components: {
      'table-search-view':TableSearchView,
      'action-info':actionOrderInfo,
      'action-deliver':actionDeliver,
    },
    data ()
    {
      return {
        searchItems: [
          {
            label: '商品名称',
            type: 'autocomplete',
            placeholder:'请输入商品名称',
            model:'goodName',
          },
          {
            label: '付款时间',
            type: 'datetimerange',
            placeholder:'请选择付款时间',
            model:'timeRange',
          },
          {
            label: '订单编号',
            type: 'input',
            placeholder:'请输入订单编号',
            model:'orderId',
          },
          {
            label: '下单用户',
            type: 'input',
            placeholder:'请输入下单用户',
            model:'userName',
          },
          {
            label: '订单状态',
            type: 'select',
            placeholder:'请选择订单状态',
            model:'state',
            multiple:false,
            filterable:true,
            options:[
              {
                label:'全部',
                value:'',
              },
              {
                label:'待发货',
                value:'pending_send_goods',
              },
              {
                label:'待发货-催促中',
                value:'pending_send_goods_reminder',
              }]
          },
        ],
        tableItems:[
          {
            label:'订单编号',
            prop:'orderNumber',
            width:'180px;',
          },
          {
            label:'商品名称',
            prop:'goodsName',
            width:'180px;',
            sortable:true,
          },
          {
            label:'下单用户',
            prop:'userName',
            width:'180px;',
            sortable:true,
          },
          {
            label:'订单金额',
            prop:'price',
            sortable:true,
            width:'150px;',
            formatter:'parsePrice',
          },
          /*{
            label:'运费',
            prop:'freight',
            width:'100px;',
            formatter:'parsePrice',
          },*/
          {
            label:'订单状态',
            prop:'stateStr',
            width:'160px;',
            sortable:true,
          },
          {
            label:'付款时间',
            prop:'firstPayTime',
            width:'160px;',
            formatter:'parseTime',
          },
          {
            type:'scope',
            slot:'action',
            label:'操作',
            width:'160px;',
          },
          {

          }
        ],
        contacts:[],
      }
    },
    mounted()
    {
    },
    methods: {
      search(data)
      {
        return getOrderPendingDeliverList(data);

        /*return new Promise(resolve => {
          let resp = {data:{total:10, list:[
            {
              "id": 89262,
              "goodsName": "iPhone 7 PLUS",
              "price": 5705,
              "userName": "VBPMAlpt",
              "state": "hXTgVuNmR5",
              "stateStr": "待发货",
              "createTime": 1505901813882,
              "freight": 10683,
              "receiveAddress": "CBO1LcGpVW",
              "firstPayTime": 1505900139865,
              "deliveryTime": 1505899547603,
              "isReminder": false
            },
            {
              "id": 89663,
              "goodsName": "iPhone 7 PLUS",
              "price": 5705,
              "userName": "VBPMAlpt",
              "state": "hXTgVuNmR5",
              "stateStr": "待发货－催促中",
              "createTime": 1505901813882,
              "freight": 10683,
              "receiveAddress": "CBO1LcGpVW",
              "firstPayTime": 1505900139865,
              "deliveryTime": 1505899547603,
              "isReminder": false
            },
            {
              "id": 89262,
              "goodsName": "iPhone 7 PLUS",
              "price": 5705,
              "userName": "VBPMAlpt",
              "state": "hXTgVuNmR5",
              "stateStr": "待发货",
              "createTime": 1505901813882,
              "freight": 10683,
              "receiveAddress": "CBO1LcGpVW",
              "firstPayTime": 1505900139865,
              "deliveryTime": 1505899547603,
              "isReminder": false
            },
            {
              "id": 89663,
              "goodsName": "iPhone 7 PLUS",
              "price": 5705,
              "userName": "VBPMAlpt",
              "state": "hXTgVuNmR5",
              "stateStr": "待发货－催促中",
              "createTime": 1505901813882,
              "freight": 10683,
              "receiveAddress": "CBO1LcGpVW",
              "firstPayTime": 1505900139865,
              "deliveryTime": 1505899547603,
              "isReminder": false
            },
            {
              "id": 89262,
              "goodsName": "iPhone 7 PLUS",
              "price": 5705,
              "userName": "VBPMAlpt",
              "state": "hXTgVuNmR5",
              "stateStr": "待发货",
              "createTime": 1505901813882,
              "freight": 10683,
              "receiveAddress": "CBO1LcGpVW",
              "firstPayTime": 1505900139865,
              "deliveryTime": 1505899547603,
              "isReminder": false
            },
            {
              "id": 89663,
              "goodsName": "iPhone 7 PLUS",
              "price": 5705,
              "userName": "VBPMAlpt",
              "state": "hXTgVuNmR5",
              "stateStr": "待发货－催促中",
              "createTime": 1505901813882,
              "freight": 10683,
              "receiveAddress": "CBO1LcGpVW",
              "firstPayTime": 1505900139865,
              "deliveryTime": 1505899547603,
              "isReminder": false
            },
            {
              "id": 89262,
              "goodsName": "iPhone 7 PLUS",
              "price": 5705,
              "userName": "VBPMAlpt",
              "state": "hXTgVuNmR5",
              "stateStr": "待发货",
              "createTime": 1505901813882,
              "freight": 10683,
              "receiveAddress": "CBO1LcGpVW",
              "firstPayTime": 1505900139865,
              "deliveryTime": 1505899547603,
              "isReminder": false
            },
            {
              "id": 89663,
              "goodsName": "iPhone 7 PLUS",
              "price": 5705,
              "userName": "VBPMAlpt",
              "state": "hXTgVuNmR5",
              "stateStr": "待发货－催促中",
              "createTime": 1505901813882,
              "freight": 10683,
              "receiveAddress": "CBO1LcGpVW",
              "firstPayTime": 1505900139865,
              "deliveryTime": 1505899547603,
              "isReminder": false
            },
            {
              "id": 89262,
              "goodsName": "iPhone 7 PLUS",
              "price": 5705,
              "userName": "VBPMAlpt",
              "state": "hXTgVuNmR5",
              "stateStr": "待发货",
              "createTime": 1505901813882,
              "freight": 10683,
              "receiveAddress": "CBO1LcGpVW",
              "firstPayTime": 1505900139865,
              "deliveryTime": 1505899547603,
              "isReminder": false
            },
            {
              "id": 89663,
              "goodsName": "iPhone 7 PLUS",
              "price": 5705,
              "userName": "VBPMAlpt",
              "state": "hXTgVuNmR5",
              "stateStr": "待发货－催促中",
              "createTime": 1505901813882,
              "freight": 10683,
              "receiveAddress": "CBO1LcGpVW",
              "firstPayTime": 1505900139865,
              "deliveryTime": 1505899547603,
              "isReminder": false
            },
          ]}};

          resolve(resp);
        });*/

      },
      successDeliver() //发货成功,调用search方法
      {
        this.$refs['orderView'].search();
      },
    }
  }
</script>
